#ifndef _OBJECT_H_
#define _OBJECT_H_

//////// object.h ////////////////////////////////////////////////////////
//    Author:        Richard (richard.lindholm85@gmail.com)             //
//    Project:    some game project                                     //
//    Version:    0.1                                                   //
//    Purpose:    Object handler,                                       //
//                Handles collision (square, perpixel)                  //
//    Comments:    Maybe I should use K.I.S.S. (Keep It Simple Stupid)  //
//                more                                                  //
//////////////////////////////////////////////////////////////////////////

#include <string>
//#include <vector>

;
using namespace std;

struct INTPOINT
{
    INTPOINT() {}
    INTPOINT(int x, int y) :
        X(x), Y(y) {}
    int X;
    int Y;
}; // *PINTPOINT;

struct FLOATPOINT
{
    FLOATPOINT() {}
    FLOATPOINT(float x, float y) :
        X(x), Y(y) {}
    float X;
    float Y;
}; // *PFLOATPOINT;

//struct OBJECT
//{
//    //object(int posX, int posY, int sizeX, int sizeY, string _name) :
//    //    pos.X(posX), pos.Y(posY), size.X(sizeX), size.Y(sizeY), name(_name) {}
//    OBJECT(INTPOINT _pos, INTPOINT _size, string _name) :
//        pos(_pos), size(_size), name(_name) {}
//    INTPOINT pos;
//    INTPOINT size;
//    FLOATPOINT velocity;
//    string name;
//
//    unsigned int state;
//    unsigned int collide;
//    unsigned int type;
//}; // *OBJECT;

enum OBJECT_STATE
{
    STATE_IDLE = 0,
    STATE_COLLIDING,
    STATE_CANTCOLLIDE,
    STATE_ERROR = 666
};

enum OBJECT_COLLIDE
{
    COLLIDE_NONE = 0,
    COLLIDE_TOP,
    COLLIDE_BOTTOM,
    COLLIDE_LEFT,
    COLLIDE_RIGHT,
    COLLIDE_ERROR = 666
};

enum OBJECT_TYPE
{
    TYPE_NONE = 0,
    TYPE_DYNAMIC,
    TYPE_STATIC,
    TYPE_ERROR = 666
};

class cGameObject
{
public:
    cGameObject();
    ~cGameObject();

    /// Set size of current object
    void setSize(int sizeX, int sizeY);
    /// Set size of current object
    void setSize(const INTPOINT size);
    /// Set position of current object
    void setPos(int posX, int posY);
    /// Set position of current object
    void setPos(const INTPOINT pos);
    void addPos(const INTPOINT add);
    void addPos(int addX, int addY);
    
    /// Get size of current object
    INTPOINT getSize();
    /// Get position of current object
    INTPOINT getPos();
    
    /// Set name of current object
    void setName(string name);
    /// Set name of current object
    void setName(const char *name);
    /// Get name of current object
    string getName();

    /// checks if objA is colliding with objB
    unsigned int isColliding(cGameObject * objA, cGameObject * objB);
    /// checks if current object is colliding with obj
    unsigned int isCollidingWith(cGameObject * obj);

    /// Set if current object can collide
    void setCanCollide(bool value);
    /// Get if current object can collide
    bool getCanCollide();

    /// Check if object is moving
    bool isObjectMoving();

    /// Set current objects velocity
    void setVelocity(FLOATPOINT velocity);
    /// Set current objects velocity
    void setVelocity(float velX, float velY);
    void setVelocityX(float velX);
    void setVelocityY(float velY);
    void addVelocity(FLOATPOINT addVel);
    void addVelocity(float addX, float addY);
    void addVelocityX(float addX);
    void addVelocityY(float addY);
    /// Get current objects velocity
    FLOATPOINT getVelocity();

    void setType(unsigned int type);
    unsigned int getType();
    void setState(unsigned int state);
    unsigned int getState();
    void setCollide(unsigned int collide);
    unsigned int getCollide();

protected:
    INTPOINT m_position;
    INTPOINT m_size;
    FLOATPOINT m_velocity;
    string m_name;

    unsigned int m_state;
    unsigned int m_collide;
    unsigned int m_type;

private:
    // some different colliding methods
    bool collideMethodA(cGameObject * objA, cGameObject * objB);
    bool collideMethodB(cGameObject * objA, cGameObject * objB);

}

#endif